home *** CD-ROM | disk | FTP | other *** search
/ MACD 5 / MACD 5.bin / workbench / blankery / blanker / source / blankers / puzzle / prefs.c < prev    next >
C/C++ Source or Header  |  1993-08-01  |  2KB  |  115 lines

  1. #include <exec/types.h>
  2.  
  3. #include <intuition/intuition.h>
  4.  
  5. #include <libraries/gadtools.h>
  6. #include <dos/dos.h>
  7.  
  8. #include <clib/exec_protos.h>
  9. #include <clib/dos_protos.h>
  10. #include <clib/intuition_protos.h>
  11. #include <clib/gadtools_protos.h>
  12.  
  13. #include "Puzzle.h"
  14. #include "Puzzle_rev.h"
  15. #include "/defs.h"
  16.  
  17. struct pPrefObject {
  18.     ULONG Horiz, Vert;
  19. };
  20.  
  21. VOID blank( VOID );
  22.  
  23. struct    pPrefObject    nP;
  24. STATIC    const    UBYTE    VersTag[] = VERSTAG;
  25. extern     struct    Task    **Task;
  26. extern        UBYTE    *prefData;
  27.  
  28. VOID setPuzzlePrefs( VOID )
  29. {
  30.         GT_SetGadgetAttrs( PuzzleGadgets[GD_HORIZ], PuzzleWnd, 0L, GTSL_Level, nP.Horiz, 0L );
  31.         GT_SetGadgetAttrs( PuzzleGadgets[GD_VERT], PuzzleWnd, 0L, GTSL_Level, nP.Vert, 0L );
  32. }
  33.  
  34. int OKClicked( VOID )
  35. {
  36.     CopyMem( &nP, prefData, sizeof( struct pPrefObject ));
  37.     return( QUIT );
  38. }
  39.  
  40. int TESTClicked( VOID )
  41. {
  42.     *Task = FindTask( 0L );
  43.     blank();
  44.     return( CONTINUE );
  45. }
  46.  
  47. int CANCELClicked( VOID )
  48. {
  49.     return( QUIT );
  50. }
  51.  
  52. int HORIZClicked( VOID )
  53. {
  54.     nP.Horiz = PuzzleMsg.Code;
  55.     return( CONTINUE );
  56. }
  57.  
  58. int VERTClicked( VOID )
  59. {
  60.     nP.Vert = PuzzleMsg.Code;
  61.     return( CONTINUE );
  62. }
  63.  
  64. int PuzzleVanillaKey( VOID )
  65. {
  66.     switch( PuzzleMsg.Code ) {
  67.     case 'o':
  68.         return( OKClicked() );
  69.     case 't':
  70.         return( TESTClicked() );
  71.     case 'c':
  72.         return( CANCELClicked() );
  73.     case 'h':
  74.         GT_SetGadgetAttrs( PuzzleGadgets[GD_HORIZ], PuzzleWnd, 0L, GTSL_Level, ++(nP.Horiz) > 14 ?
  75.             nP.Horiz = 14 : nP.Horiz, 0L );
  76.         return( CONTINUE );
  77.     case 'H':
  78.         GT_SetGadgetAttrs( PuzzleGadgets[GD_HORIZ], PuzzleWnd, 0L, GTSL_Level, --(nP.Horiz) < 2 ?
  79.             nP.Horiz = 2 : nP.Horiz , 0L );
  80.         return( CONTINUE );
  81.     case 'v':
  82.         GT_SetGadgetAttrs( PuzzleGadgets[GD_VERT], PuzzleWnd, 0L, GTSL_Level, ++(nP.Vert) > 10 ?
  83.             nP.Vert = 10 : nP.Vert, 0L );
  84.         return( CONTINUE );
  85.     case 'V':
  86.         GT_SetGadgetAttrs( PuzzleGadgets[GD_VERT], PuzzleWnd, 0L, GTSL_Level, --(nP.Vert) < 2 ?
  87.             nP.Vert = 2 : nP.Vert, 0L );
  88.         return( CONTINUE );
  89.     default:
  90.         return( CONTINUE );
  91.     }
  92. }
  93.  
  94. VOID prefs( LONG command )
  95. {
  96.     switch( command ) {
  97.     case STARTUP:
  98.         CopyMem( prefData, &nP, sizeof( struct pPrefObject ));
  99.         if( !SetupScreen() ) {
  100.             if( !OpenPuzzleWindow()) setPuzzlePrefs();
  101.             CloseDownScreen();
  102.         }
  103.         break;
  104.     case IDCMP:
  105.         if( HandlePuzzleIDCMP() != QUIT ) break;
  106.     case KILL:
  107.         ClosePuzzleWindow();
  108.     }
  109. }
  110.  
  111. LONG winSig( VOID )
  112. {
  113.     return( PuzzleWnd ? ( 1L << PuzzleWnd->UserPort->mp_SigBit ) : 0L );
  114. }
  115.